/**
 * <copyright>
 * </copyright>
 *

 */
package ms.unicorn.language.languagedef.impl;

import java.util.Collection;

import ms.unicorn.language.languagedef.ElementDef;
import ms.unicorn.language.languagedef.LanguagedefPackage;
import ms.unicorn.language.languagedef.Parameter;
import ms.unicorn.language.languagedef.Policies;
import ms.unicorn.language.languagedef.TagDef;
import ms.unicorn.language.languagedef.XReferenceExpression;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Element Def</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#isInherited <em>Inherited</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getText <em>Text</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getSmallImage <em>Small Image</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getLargeImage <em>Large Image</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getFigureParams <em>Figure Params</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getFigure <em>Figure</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getView <em>View</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getHelper <em>Helper</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getPolicies <em>Policies</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ElementDefImpl#getTags <em>Tags</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ElementDefImpl extends ModuleItemImpl implements ElementDef
{
  /**
   * The default value of the '{@link #isInherited() <em>Inherited</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isInherited()
   * @generated
   * @ordered
   */
  protected static final boolean INHERITED_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isInherited() <em>Inherited</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isInherited()
   * @generated
   * @ordered
   */
  protected boolean inherited = INHERITED_EDEFAULT;

  /**
   * The default value of the '{@link #getText() <em>Text</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getText()
   * @generated
   * @ordered
   */
  protected static final String TEXT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getText() <em>Text</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getText()
   * @generated
   * @ordered
   */
  protected String text = TEXT_EDEFAULT;

  /**
   * The default value of the '{@link #getSmallImage() <em>Small Image</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSmallImage()
   * @generated
   * @ordered
   */
  protected static final String SMALL_IMAGE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getSmallImage() <em>Small Image</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSmallImage()
   * @generated
   * @ordered
   */
  protected String smallImage = SMALL_IMAGE_EDEFAULT;

  /**
   * The default value of the '{@link #getLargeImage() <em>Large Image</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLargeImage()
   * @generated
   * @ordered
   */
  protected static final String LARGE_IMAGE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getLargeImage() <em>Large Image</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLargeImage()
   * @generated
   * @ordered
   */
  protected String largeImage = LARGE_IMAGE_EDEFAULT;

  /**
   * The cached value of the '{@link #getFigureParams() <em>Figure Params</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFigureParams()
   * @generated
   * @ordered
   */
  protected EList<Parameter> figureParams;

  /**
   * The cached value of the '{@link #getFigure() <em>Figure</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFigure()
   * @generated
   * @ordered
   */
  protected XReferenceExpression figure;

  /**
   * The cached value of the '{@link #getView() <em>View</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getView()
   * @generated
   * @ordered
   */
  protected XReferenceExpression view;

  /**
   * The default value of the '{@link #getHelper() <em>Helper</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHelper()
   * @generated
   * @ordered
   */
  protected static final String HELPER_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getHelper() <em>Helper</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHelper()
   * @generated
   * @ordered
   */
  protected String helper = HELPER_EDEFAULT;

  /**
   * The cached value of the '{@link #getPolicies() <em>Policies</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPolicies()
   * @generated
   * @ordered
   */
  protected Policies policies;

  /**
   * The cached value of the '{@link #getTags() <em>Tags</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTags()
   * @generated
   * @ordered
   */
  protected EList<TagDef> tags;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ElementDefImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LanguagedefPackage.Literals.ELEMENT_DEF;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isInherited()
  {
    return inherited;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInherited(boolean newInherited)
  {
    boolean oldInherited = inherited;
    inherited = newInherited;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__INHERITED, oldInherited, inherited));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getText()
  {
    return text;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setText(String newText)
  {
    String oldText = text;
    text = newText;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__TEXT, oldText, text));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getSmallImage()
  {
    return smallImage;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSmallImage(String newSmallImage)
  {
    String oldSmallImage = smallImage;
    smallImage = newSmallImage;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__SMALL_IMAGE, oldSmallImage, smallImage));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getLargeImage()
  {
    return largeImage;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setLargeImage(String newLargeImage)
  {
    String oldLargeImage = largeImage;
    largeImage = newLargeImage;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__LARGE_IMAGE, oldLargeImage, largeImage));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Parameter> getFigureParams()
  {
    if (figureParams == null)
    {
      figureParams = new EObjectContainmentEList<Parameter>(Parameter.class, this, LanguagedefPackage.ELEMENT_DEF__FIGURE_PARAMS);
    }
    return figureParams;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XReferenceExpression getFigure()
  {
    return figure;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetFigure(XReferenceExpression newFigure, NotificationChain msgs)
  {
    XReferenceExpression oldFigure = figure;
    figure = newFigure;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__FIGURE, oldFigure, newFigure);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFigure(XReferenceExpression newFigure)
  {
    if (newFigure != figure)
    {
      NotificationChain msgs = null;
      if (figure != null)
        msgs = ((InternalEObject)figure).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.ELEMENT_DEF__FIGURE, null, msgs);
      if (newFigure != null)
        msgs = ((InternalEObject)newFigure).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.ELEMENT_DEF__FIGURE, null, msgs);
      msgs = basicSetFigure(newFigure, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__FIGURE, newFigure, newFigure));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XReferenceExpression getView()
  {
    return view;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetView(XReferenceExpression newView, NotificationChain msgs)
  {
    XReferenceExpression oldView = view;
    view = newView;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__VIEW, oldView, newView);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setView(XReferenceExpression newView)
  {
    if (newView != view)
    {
      NotificationChain msgs = null;
      if (view != null)
        msgs = ((InternalEObject)view).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.ELEMENT_DEF__VIEW, null, msgs);
      if (newView != null)
        msgs = ((InternalEObject)newView).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.ELEMENT_DEF__VIEW, null, msgs);
      msgs = basicSetView(newView, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__VIEW, newView, newView));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getHelper()
  {
    return helper;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHelper(String newHelper)
  {
    String oldHelper = helper;
    helper = newHelper;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__HELPER, oldHelper, helper));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Policies getPolicies()
  {
    return policies;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetPolicies(Policies newPolicies, NotificationChain msgs)
  {
    Policies oldPolicies = policies;
    policies = newPolicies;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__POLICIES, oldPolicies, newPolicies);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPolicies(Policies newPolicies)
  {
    if (newPolicies != policies)
    {
      NotificationChain msgs = null;
      if (policies != null)
        msgs = ((InternalEObject)policies).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.ELEMENT_DEF__POLICIES, null, msgs);
      if (newPolicies != null)
        msgs = ((InternalEObject)newPolicies).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.ELEMENT_DEF__POLICIES, null, msgs);
      msgs = basicSetPolicies(newPolicies, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.ELEMENT_DEF__POLICIES, newPolicies, newPolicies));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<TagDef> getTags()
  {
    if (tags == null)
    {
      tags = new EObjectContainmentEList<TagDef>(TagDef.class, this, LanguagedefPackage.ELEMENT_DEF__TAGS);
    }
    return tags;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LanguagedefPackage.ELEMENT_DEF__FIGURE_PARAMS:
        return ((InternalEList<?>)getFigureParams()).basicRemove(otherEnd, msgs);
      case LanguagedefPackage.ELEMENT_DEF__FIGURE:
        return basicSetFigure(null, msgs);
      case LanguagedefPackage.ELEMENT_DEF__VIEW:
        return basicSetView(null, msgs);
      case LanguagedefPackage.ELEMENT_DEF__POLICIES:
        return basicSetPolicies(null, msgs);
      case LanguagedefPackage.ELEMENT_DEF__TAGS:
        return ((InternalEList<?>)getTags()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LanguagedefPackage.ELEMENT_DEF__INHERITED:
        return isInherited();
      case LanguagedefPackage.ELEMENT_DEF__TEXT:
        return getText();
      case LanguagedefPackage.ELEMENT_DEF__SMALL_IMAGE:
        return getSmallImage();
      case LanguagedefPackage.ELEMENT_DEF__LARGE_IMAGE:
        return getLargeImage();
      case LanguagedefPackage.ELEMENT_DEF__FIGURE_PARAMS:
        return getFigureParams();
      case LanguagedefPackage.ELEMENT_DEF__FIGURE:
        return getFigure();
      case LanguagedefPackage.ELEMENT_DEF__VIEW:
        return getView();
      case LanguagedefPackage.ELEMENT_DEF__HELPER:
        return getHelper();
      case LanguagedefPackage.ELEMENT_DEF__POLICIES:
        return getPolicies();
      case LanguagedefPackage.ELEMENT_DEF__TAGS:
        return getTags();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LanguagedefPackage.ELEMENT_DEF__INHERITED:
        setInherited((Boolean)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__TEXT:
        setText((String)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__SMALL_IMAGE:
        setSmallImage((String)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__LARGE_IMAGE:
        setLargeImage((String)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__FIGURE_PARAMS:
        getFigureParams().clear();
        getFigureParams().addAll((Collection<? extends Parameter>)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__FIGURE:
        setFigure((XReferenceExpression)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__VIEW:
        setView((XReferenceExpression)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__HELPER:
        setHelper((String)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__POLICIES:
        setPolicies((Policies)newValue);
        return;
      case LanguagedefPackage.ELEMENT_DEF__TAGS:
        getTags().clear();
        getTags().addAll((Collection<? extends TagDef>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.ELEMENT_DEF__INHERITED:
        setInherited(INHERITED_EDEFAULT);
        return;
      case LanguagedefPackage.ELEMENT_DEF__TEXT:
        setText(TEXT_EDEFAULT);
        return;
      case LanguagedefPackage.ELEMENT_DEF__SMALL_IMAGE:
        setSmallImage(SMALL_IMAGE_EDEFAULT);
        return;
      case LanguagedefPackage.ELEMENT_DEF__LARGE_IMAGE:
        setLargeImage(LARGE_IMAGE_EDEFAULT);
        return;
      case LanguagedefPackage.ELEMENT_DEF__FIGURE_PARAMS:
        getFigureParams().clear();
        return;
      case LanguagedefPackage.ELEMENT_DEF__FIGURE:
        setFigure((XReferenceExpression)null);
        return;
      case LanguagedefPackage.ELEMENT_DEF__VIEW:
        setView((XReferenceExpression)null);
        return;
      case LanguagedefPackage.ELEMENT_DEF__HELPER:
        setHelper(HELPER_EDEFAULT);
        return;
      case LanguagedefPackage.ELEMENT_DEF__POLICIES:
        setPolicies((Policies)null);
        return;
      case LanguagedefPackage.ELEMENT_DEF__TAGS:
        getTags().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.ELEMENT_DEF__INHERITED:
        return inherited != INHERITED_EDEFAULT;
      case LanguagedefPackage.ELEMENT_DEF__TEXT:
        return TEXT_EDEFAULT == null ? text != null : !TEXT_EDEFAULT.equals(text);
      case LanguagedefPackage.ELEMENT_DEF__SMALL_IMAGE:
        return SMALL_IMAGE_EDEFAULT == null ? smallImage != null : !SMALL_IMAGE_EDEFAULT.equals(smallImage);
      case LanguagedefPackage.ELEMENT_DEF__LARGE_IMAGE:
        return LARGE_IMAGE_EDEFAULT == null ? largeImage != null : !LARGE_IMAGE_EDEFAULT.equals(largeImage);
      case LanguagedefPackage.ELEMENT_DEF__FIGURE_PARAMS:
        return figureParams != null && !figureParams.isEmpty();
      case LanguagedefPackage.ELEMENT_DEF__FIGURE:
        return figure != null;
      case LanguagedefPackage.ELEMENT_DEF__VIEW:
        return view != null;
      case LanguagedefPackage.ELEMENT_DEF__HELPER:
        return HELPER_EDEFAULT == null ? helper != null : !HELPER_EDEFAULT.equals(helper);
      case LanguagedefPackage.ELEMENT_DEF__POLICIES:
        return policies != null;
      case LanguagedefPackage.ELEMENT_DEF__TAGS:
        return tags != null && !tags.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (inherited: ");
    result.append(inherited);
    result.append(", text: ");
    result.append(text);
    result.append(", smallImage: ");
    result.append(smallImage);
    result.append(", largeImage: ");
    result.append(largeImage);
    result.append(", helper: ");
    result.append(helper);
    result.append(')');
    return result.toString();
  }

} //ElementDefImpl
